<template>
  <div class="container">
    <img class="banner" src="@/assets/user-banner.png" alt="" />
    <div class="list">
      <div class="list-content" v-for="item in list" :key="item.id">
        <div class="wrap">
          <div class="upper">
            <div class="title">
              <p>{{ item.title_cn }}</p>
              <span>{{ item.date }} 地点：{{ item.location }}</span>
              <router-link
                :to="{
                  path: '/eventList',
                  query: {
                    id: item.id,
                  },
                }"
                class="more"
              >
                More >
              </router-link>
            </div>
          </div>
          <div class="list">
            <div class="col" v-for="col in item.top_imates" :key="col.id">
              <router-link
                :to="{
                  path: '/eventDetail',
                  query: {
                    id: col.id,
                  },
                }"
              >
                <div class="item imgDiv">
                  <img :src="col.image_url" alt="" />
                </div>
              </router-link>
            </div>
          </div>
        </div>
      </div>
    </div>
    <pagination
      :total="total"
      :currentPage="page"
      :pageSize="rows"
      @handleCurrentChange="handleCurrentChange"
    />
    <payment :show.sync="show" />
  </div>
</template>

<script>
export default {
  name: "NavBar",
  data() {
    return {
      page: 1,
      rows: 9,
      total: 0,
      list: [],
      show: false,
    };
  },
  components: {
    pagination: () => import("@/components/pagination.vue"),
    payment: () => import("@/components/payment.vue"),
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      this.$post("/index/events_list", {
        page: this.page,
        rows: this.rows,
      }).then((res) => {
        this.list = res.data.data;
        this.total = res.data.total;
      });
    },
    handleCurrentChange(e) {
      this.page = e;
      this.getList();
    },
    download(item) {
      this.show = true;
    },
    collect(item) {
      this.$post("/user/favorite", { image_sn: item.id });
    },
  },
};
</script>

<style scoped lang="scss">
.banner {
  height: 300px;
}
.title {
  text-align: center;
  position: relative;
  margin-bottom: 40px;
  p {
    font-weight: bold;
    font-size: 48px;
  }

  .more {
    position: absolute;
    right: 0%;
    bottom: 10px;
  }
}
.list-content {
  padding: 40px 0 90px;
  background: url("@/assets/index-bg.png") bottom center no-repeat;
  background-size: 100%;

  .list {
    display: flex;
    flex-wrap: wrap;
    margin: -8px;
    .col {
      width: calc(100% / 3);
      padding: 8px;
      .imgDiv {
        border-radius: 20px;
      }
    }
  }
}

@media screen and (max-width: 1024px) {
  .title p {
    font-size: 30px;
  }
  .title {
    padding-bottom: 25px;
    .more {
      position: absolute;
      right: 0%;
      bottom: 0;
    }
  }
}
@media screen and (max-width: 768px) {
  .title p {
    font-size: 22px;
  }
  .list-content {
    padding: 40px 0 10px;
  }
  .list-content .list .col {
    width: 50%;
  }
  .list-content .list .col .imgDiv:hover .content {
    display: none;
  }
}
</style>
